﻿using CarAppDto.Base;
using FluentValidation;

namespace CarAppDto.Rule.RuleConfigDtos
{
    /// <summary>
    ///数据校验类要继承自 AbstractValidator
    ///通过 AbstractValidator 的泛型参数指定对哪个类进行校验
    /// </summary>
    public class ReqUpdateRuleConfigValidator : AbstractValidator<ReqUpdateRuleConfig>
    {
        /// <summary>
        /// 校验规则写到校验类的构造方法中
        /// </summary>
        public ReqUpdateRuleConfigValidator()
        {
            // 通过RuleFor来指定要对哪个属性进行校验
            // 多个校验规则可以采用链式调用的写法
            // 每个需要校验的属性对应一组RuleFor调用
            RuleFor(x => x.Id).NotEmpty();
            RuleFor(x => x.Name).NotEmpty();
            RuleFor(x => x.No).NotEmpty().Length(6, 18);
            RuleFor(x => x.BrandId).NotEmpty();
            RuleFor(x => x.RuleConfigDetailsList).NotEmpty();
        }
    }
    /// <summary>
    /// 修改规则组成
    /// </summary>
    public class ReqUpdateRuleConfig : BaseUpdateModel
    {

        /// <summary>
        /// 规则名称
        /// </summary>
        public string? Name { get; set; }

        /// <summary>
        /// 规则编号
        /// </summary>
        public string? No { get; set; }

        /// <summary>
        /// 所属品牌代码
        /// </summary>
        public string? BrandId { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        public string? Descption { get; set; }

        /// <summary>
        /// 规则详情
        /// </summary>
        public List<RuleConfigDetails> RuleConfigDetailsList { get; set; } = new List<RuleConfigDetails>();
    }
}
